# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python


class Recipe(recipe.Recipe):
    name = 'harfbuzz'
    version = '2.6.1'
    stype = SourceType.TARBALL
    url = 'https://www.freedesktop.org/software/%(name)s/release/%(name)s-%(version)s.tar.xz'
    tarball_checksum = 'c651fb3faaa338aeb280726837c2384064cdc17ef40539228d88a1260960844f'
    licenses = [{License.BSD_like: ['COPYING']}]
    deps = ['fontconfig', 'cairo', 'glib']
    configure_options = "--enable-static --with-icu=no"
    autoreconf = True

    files_bins = ['hb-ot-shape-closure', 'hb-view', 'hb-shape']
    files_libs = ['libharfbuzz']
    files_devel = ['include/harfbuzz/*.h', 'lib/pkgconfig/harfbuzz.pc']

    def prepare(self):
        if self.config.platform != Platform.WINDOWS:
            self.patches = ['harfbuzz/0001-Use-Python3-in-gen-def.py.patch']

        if self.config.target_platform == Platform.ANDROID:
            v = DistroVersion.get_android_api_version(self.config.target_distro_version)
            if self.config.target_arch in [Architecture.ARM, Architecture.ARMv7, Architecture.X86] and v < 21:
                # FIXME: HACK to make projects using mmap compile with NDK 16
                # we fail to compile with -D_FILE_OFFSET_BITS=64
                # because we don't use clang and we use a platform < 21 (Lollipop)
                # See $NDK_ROOT/sysroot/usr/include/sys/mman.h as one example
                self.set_env('ac_cv_func_mmap', 'no')
